package com.Helper;

import java.sql.*;
import java.util.*;

import com.database.CustomerDB;
import com.database.FlightDB;

public class CustomerHelper 
{
	private static Connection connection = null;
	
	public static void Setup(Connection _connection) throws SQLException
	{
		connection = _connection;
	}
	
	public static CustomerInfo GetSelectedCustomer(String username) throws SQLException
	{
		CustomerDB db = new CustomerDB();
		db.Setup(connection);
		CustomerInfo info = db.GetSelectedCustomer(username);
		return info;
	}
	
	public static void AddPoint(String username, int point) throws SQLException
	{
		CustomerDB db = new CustomerDB();
		db.Setup(connection);
		CustomerInfo info = db.GetSelectedCustomer(username);
		
		int total = info.point + point;
		db.ModPoints(total, username);
	}
	
	public static boolean ModPoint(String username, int point) throws SQLException
	{
		CustomerDB db = new CustomerDB();
		db.Setup(connection);
		CustomerInfo info = db.GetSelectedCustomer(username);
		
		if ((info.point + point) < 0)
		{
			return false;
		}
		else
		{
			info.point -= point;
			db.ModPoints(info.point, username);
			return true;
		}
	}
	
	public static boolean ModPaidPrice(String username, float price) throws SQLException
	{
		CustomerDB db = new CustomerDB();
		db.Setup(connection);
		CustomerInfo info = db.GetSelectedCustomer(username);
		
		return false;
	}
	

	

	
}
